# print("hell world")
import time

print("*******欢迎进入随机商城********")
dumiao = 3
while dumiao > 0:
    print("正在整理商品，请等待", dumiao, "秒")
    time.sleep(1)
    dumiao -= 1
# time.sleep(5)
print()
products = [["iphone", 6888, "促销"], ["MacPro", 14800], ["小米6", 2499, "促销"], ["Coffee", 310], ["Book", 600],
            ["Nike", 699]]

print("-------商品列表---------")
print("编号\t商品名称\t价格\t\t活动")
a = len(products)
while a > 0:
    b = len(products[len(products) - a])
    print(len(products) - a + 1, end="\t")  # 显示编号
    while b > 0:
        print(products[len(products) - a][len(products[len(products) - a]) - b], end="\t")
        b -= 1
    print()
    a -= 1

print("请输入商品编号来进行购买")
shop_cost = []
while 1:
    incar = input("购买商品编号为：")
    if ord(incar) == ord('q'):
        print("正在打印购物清单，请稍后")
        if len(shop_cost) == 0:
            print("您好像什么都没有购买。")
            break
        else:
            pruductCount = len(shop_cost)
            while pruductCount > 0:
                attributeCount = len(shop_cost[len(shop_cost) - pruductCount])
                print(len(shop_cost) - pruductCount + 1, end="\t")  # 显示编号
                while attributeCount > 0:
                    print(shop_cost[len(shop_cost) - pruductCount][
                              len(shop_cost[len(shop_cost) - pruductCount]) - attributeCount], end="\t")
                    attributeCount -= 1
                print()
                pruductCount -= 1
            break
    elif ord(incar) < ord(str(1)) or ord(incar) > ord(str(len(products))):
        print("请选择正确的编号！")
        continue
    else:
        shop_cost.append(products[int(incar) - 1])
        print("您已经将", products[int(incar) - 1][0], "加入购物车，请继续购物或按q结束购物。")

# shop = input("购买产品：")
# print(shop)
